<template>
  <el-form :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4">
    <el-form-item label="手机号" prop="phone" :rules="[{required: true,message: '手机号必须填写'}]">
  <el-input v-model="formData.phone" name="phone" clearable />
</el-form-item>
<el-form-item label="状态" prop="status" :rules="[{required: true,message: '状态必选'}]">
  <el-select v-model="formData.status" placeholder="请选择">
        <el-option
          v-for="item in Status"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
    </el-select>
  <!-- <el-input v-model="formData.status" name="status" clearable /> -->
</el-form-item>
<el-form-item label="运营商渠道" prop="channel">
  <el-input v-model="formData.channel" name="channel" clearable />
</el-form-item>
<el-form-item label="锁号状态" prop="temp_status" :rules="[{required: true,message: '锁号状态必选'}]">
  <el-select v-model="formData.temp_status" placeholder="请选择">
        <el-option
          v-for="item in temp_Status"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
    </el-select>
  <!-- <el-input v-model="formData.temp_status" name="temp_status" clearable /> -->
</el-form-item>
<el-form-item label="锁号时间" prop="lock_time">
  <!-- <el-input v-model="formData.lock_time" name="lock_time" clearable /> -->
           <el-date-picker
              v-model="formData.lock_time"
              type="datetime"
              format="YYYY/MM/DD HH:mm"
              value-format="YYYY/MM/DD HH:mm"
              placeholder="同步接口锁定时间"
            />
</el-form-item>
<el-form-item label="商品编码/套餐ID" prop="commodity_code">
  <el-input v-model="formData.commodity_code" name="commodity_code" clearable />
</el-form-item>
    <div class="flex justify-end">
      <el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import { useCreate } from '@/composables/curd/useCreate'
import { useShow } from '@/composables/curd/useShow'
import { onMounted, ref } from 'vue'

const props = defineProps({
  primary: [String, Number],
  api: String,
})

const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)
const temp_Status = ref([{ value: 1, label: '已锁号' },{value:2,label:'未锁号'}])
const Status = ref([{ value: 1, label: '可使用' },{value:2,label:'已使用'},{value:3,label:'异常'}])
if (props.primary) {
  useShow(props.api, props.primary, formData)
}

const emit = defineEmits(['close'])
onMounted(() => {
  close(() => emit('close'))
})
</script>
